Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR integrates Prettier and ESLint for consistent code formatting and linting across the project.
- Adds Prettier and ESLint configs, updates
package.jsonscripts accordingly - Reformats imports and code ordering in middleware, tests, and database modules
- Introduces graceful shutdown logic, refines type annotations, and uses nullish coalescing
Reviewed Changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/midleware/morgan.ts | Simplified import by removing unused StreamOptions |
| src/midleware/json.ts | Reordered JSON middleware options and tightened reviver types |
| src/midleware/helmet.ts | Reordered helmet options and moved referrerPolicy |
| src/midleware/errorHandler.ts | Marked unused params, disabled lint warning, added stack fallback |
| src/midleware/cors.ts | Switched env defaults to nullish coalescing and trimmed arrays |
| src/index.ts | Added dotenv import, graceful shutdown, updated startServer() |
| src/http_tests/stores.test.ts | Added type casts, extracted body, conditional ID checks |
| src/http_tests/authentication.test.ts | Defined response interface, typed responses, added profile test |
| src/http_tests/app.test.ts | Added response interface, unified status assertions |
| src/database/stores.ts | Refactored CRUD returns, moved getStores(), type-safe mapping |
| src/database/mongo-common.ts | Reordered imports, env var fallback, unified getDatabase() |
| src/app.ts | Reordered middleware imports |
| package.json | Added private flag, import maps, lint/format scripts, deps |
| eslint.config.js | New ESLint configuration |
| README.md | Updated environment docs and scripts examples |
| .prettierrc | New Prettier configuration |
| .prettierignore | Added ignore patterns |
| .env.sample | Added JWT_SECRET to sample variables |
Comments suppressed due to low confidence (2)
src/http_tests/stores.test.ts:55
- The test silently skips assertions when
storeIdis undefined, potentially hiding failures. Add an explicitexpect(storeId).toBeDefined()before the conditional to ensure the setup succeeded.
if (storeId) {
README.md:17
- The environment variable name is mistyped as
NODE\*ENV. It should readNODE_ENV=testand the markdown escaping can be simplified for clarity.
6. NODE\*ENV=test --- When set to \*\*\*"test"\_\*\*...
| .expect(200); | ||
|
|
||
| expect(res.statusCode).toEqual(200); | ||
| expect(body).toHaveProperty('email', testUser.email); |
There was a problem hiding this comment.
This assertion uses body from the login response instead of the profile response. You should extract and assert against the res.body of the GET /auth/me request.
| expect(body).toHaveProperty('email', testUser.email); | |
| const profileBody = res.body; | |
| expect(profileBody).toHaveProperty('email', testUser.email); |
| const database = await getDatabase(); | ||
| const stores = await database.collection<Store>(collectionName).find({}).toArray(); | ||
| return stores.map(store => ({ | ||
| _id: new ObjectId(store._id), |
There was a problem hiding this comment.
Re-wrapping an existing ObjectId is unnecessary and could lead to confusion; you can return store._id directly since it’s already the correct type.
| _id: new ObjectId(store._id), | |
| _id: store._id, |
| }); | ||
|
|
||
| startServer(); No newline at end of file | ||
| void startServer() No newline at end of file |
There was a problem hiding this comment.
[nitpick] Add a semicolon after void startServer() to comply with the project's Prettier semi: true rule and maintain consistency.
| void startServer() | |
| void startServer(); |
No description provided.